/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2024-02-03
 * Time: 10:53
 */
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入第一个字符串：");
        String s1 = scanner.nextLine();
        System.out.println("请输入第二个字符串：");
        String s2 = scanner.nextLine();

        String result = stringMerge(s1, s2);
        System.out.println("交叉合并后的字符串为：" + result);
    }

    public static String stringMerge(String s1, String s2) {
        StringBuilder result = new StringBuilder();
        int len1 = s1.length();
        int len2 = s2.length();
        int i = 0, j = 0;

        // 有一个字符串结束就结束
        while (i < len1 && j < len2) {
            result.append(Character.toUpperCase(s1.charAt(i)));
            result.append(Character.toUpperCase(s2.charAt(j)));
            i++;
            j++;
        }

        // 把另一个字符串剩下部分直接添加到合并字符串后面
        while (i < len1) {
            result.append(Character.toUpperCase(s1.charAt(i)));
            i++;
        }
        while (j < len2) {
            result.append(Character.toUpperCase(s2.charAt(j)));
            j++;
        }

        return result.toString();
    }
}